SRCS	:= $(wildcard *.cpp)

CC		= g++
INCPATH	= ../include
#CCFLAG	= -I $(INCPATH) -c -g -O3 -static
CCFLAG	= -I $(INCPATH) -c -g -static
BUILD_DIR = build

UTILS_OBJS = UTIL.o SYSCALL.o GLOBAL.o MemoryManager.o

ENGINE_OBJS = VInst.o VBlockBuilder.o VBasicBlockBuilder.o TBlock.o TCache.o TraceManager.o ExecutionEngine.o SignalHandler.o 

OPT_OBJS = VFilter.o InstructionReorderFilter.o SSAFormFilter.o RedundancyEliminateFilter.o PrintFilter.o ConstExpEvalFilter.o V0Filter.o RedVMRegUpdateFilter.o CopyPropagationFilter.o

TCACHE_OBJS = SimpleTCache.o

MEMORY_IMAGE_OBJS = ELFMemoryImage.o

REG_ALLOCATOR_OBJS = NextUseRegAllocator.o SimpleRegAllocator.o GlobalRegAllocator.o GraphRegAllocator.o LeastUseRegAllocator.o 

PROFILER_OBJS = Profiler.o

LIBCROSSBIT_OBJS = $(UTILS_OBJS) $(ENGINE_OBJS) $(TCACHE_OBJS) $(MEMORY_IMAGE_OBJS) $(REG_ALLOCATOR_OBJS) $(PROFILER_OBJS) $(OPT_OBJS) 

all: $(LIBCROSSBIT_OBJS)
#	ar -r libcrossbit.a $(BUILD_DIR)/*.o
	ar -r libcrossbit.a *.o
	@echo "done!"

$(LIBCROSSBIT_OBJS):%.o:%.cpp
#	$(CC) $(CCFLAG) $(CFLAGS) $? -o $(BUILD_DIR)/$@
	$(CC) $(CCFLAG) $(CFLAGS) $? -o $@

clean:
#	rm -rf $(BUILD_DIR)/*.o
	rm -rf ./*.o
	rm -f *.a
